<?php

namespace App\Http\Controllers\Api\V1;

use App\Models\Agency;
use App\Models\Device;
use Illuminate\Http\Request;


class SnapshotController extends BaseController
{
    /**
     *
     * @Date 2020/9/10 下午5:40
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @todo 根据条件返回查询的记录信息
     */
    public function verify(Request $request)
    {
        $this->validate($request, [
            'code' => 'required|string',
        ], [], []);

        $device = Device::where("code", $request->input("code"))->first();
        if(empty($device)){
            $agencies = Agency::all(['id', 'name']);
            return $this->json(['is_register'=>0, 'agnecies'=>$agencies]);
        }

        return $this->json(['is_register'=>1]);
    }

}
